package com.matrix.draft.sockettest.newprotocoltcp.handler;

import com.matrix.draft.sockettest.newprotocoltcp.pojo.MyMessage;
import com.matrix.draft.sockettest.newprotocoltcp.pojo.StringMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ServerHandler extends SimpleChannelInboundHandler<MyMessage> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MyMessage msg) throws Exception {
        // 读取
        log.debug("Server Receiving : {}", msg.getContent());
        // 回应
        ctx.pipeline().writeAndFlush(new StringMessage("收到, Over"));
    }
}